###################################################################
# 新思路
# 2017年6月28日15:13:33
# 
# 配置daocloud.io加速器
# window: http://c6a5680e.m.daocloud.io
# linux: curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://c6a5680e.m.daocloud.io
# mac: http://c6a5680e.m.daocloud.io
#
### 0 修改docker加速器 修改docker共享本地磁盘 切换PowerShell到当前项目目录
# 
### 1.1 (如php-new-think-img镜像不存在) 切换PowerShell到new-think项目根目录下, 编译new-think镜像
# docker build -t php-new-think-img .
### 1.2 (如php-yayi-admin-img镜像不存在) 切换PowerShell到yayi-admin项目根目录下, 编译yayi-admin镜像
# docker build -t php-yayi-admin-img .
### 1.3 (如yayi-proxy-img镜像不存在) 切换PowerShell到yayi-proxy项目根目录下, 编译yayi-proxy镜像
# docker build -t yayi-proxy-img .
### 1.4 (如block-proxy-img镜像不存在) 切换PowerShell到block-proxy项目根目录下, 编译block-proxy镜像
# docker build -t block-proxy-img .
### 1.5 (如yayi-home-img镜像不存在) 切换PowerShell到yayi-home项目根目录下, 编译yayi-home镜像
# docker build -t php-yayi-home-img .
### 1.6 (如zhenglu-php-img镜像不存在) 切换PowerShell到zhenglu-php项目根目录下, 编译zhenglu-php镜像
# docker build -t zhenglu-php-img .
### 1.7 (如yihuo-home-img镜像不存在) 切换PowerShell到yihuo-home项目根目录下, 编译yihuo-home镜像
# docker build -t php-yihuo-home-img .
### 1.8 (如block-home-img镜像不存在) 切换PowerShell到block-home项目根目录下, 编译block-home镜像
# docker build -t php-block-home-img .
### 1.9 (如block-admin-img镜像不存在) 切换PowerShell到block-admin项目根目录下, 编译block-admin镜像
# docker build -t php-block-admin-img .
### 1.10 (如ec-home-img镜像不存在) 切换PowerShell到ec-home项目根目录下, 编译ec-home镜像
# docker build -t php-ec-home-img .
### 1.11 (如block-new-think-img镜像不存在) 切换PowerShell到block-new-think项目根目录下, 编译block-new-think镜像
# docker build -t php-block-new-think-img .
#
### 2.1 启动mysql镜像, 生成容器
# 本地测试:
# docker run --name newthink-mysql -v /d/mysqldata/newthink:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=caoshijie_sikao -p 3306:3306 -d mysql:8.0.1
# docker run --name block-mysql -v /d/mysqldata/block:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=caoshijie_sikao -p 3310:3306 -d mysql:8.0.1
# 阿里云:
# docker run --name newthink-mysql -v /mysqldata/newthink:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=caoshijie_sikao -p 3306:3306 -d mysql:8.0.1
# 2.2 正路的mysql占用3307公开端口
# docker run -v /mysqldata/zhenglu:/var/lib/mysql --name zhenglu-mysql -p 3307:3306 -e MYSQL_ROOT_PASSWORD=ZEE230D048B3556E759FD01E195A0EF1A61A2F0Z5 -d mysql:5.6
# 2.3 枣庄惠煤的数据库3308端口
# docker run -v /mysqldata/huimei:/var/lib/mysql --name huimei-mysql -p 3308:3306 -e MYSQL_ROOT_PASSWORD=ZEE230D048B3556E759FD01E195A0EF1A61A2F0Z5 -d mysql:5.6
# 2.4 网红数据库3309端口
# docker run --name celebrity-mysql -v /mysqldata/celebrity:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=caoshijie_sikao -p 3309:3306 -d mysql:8.0.1
# 2.5 品码证书系统数据库端口3310端口
# docker run --name block-mysql -v /mysqldata/block:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=caoshijie_sikao -p 3310:3306 -d mysql:8.0.1
#
### 3 启动redis镜像, 生成容器 可以将-v 后的 `/d/data/redis` 换成你自己的redis数据目录
# docker run --name newthink-redis -d -v /d/redisdata/newthink:/data redis redis-server --appendonly yes
# docker run --name block-redis -d -v /d/redisdata/block:/data redis redis-server --appendonly yes
#
### 4.1 启动 php-new-think-img 镜像, 生成容器
# docker run --name php-new-think-app -d -v /d/work/new-think:/var/www/html/new-think --link newthink-mysql:mysql --link newthink-redis:redis php-new-think-img:latest
### 4.2 启动 php-yayi-admin-img 镜像, 生成容器
# docker run --name php-yayi-admin-app -d -v /d/work/yayi-admin:/var/www/html/yayi-admin --link newthink-mysql:mysql --link newthink-redis:redis php-yayi-admin-img:latest
### 4.3 启动 php-yayi-home-img 镜像, 生成容器
# docker run --name php-yayi-home-app -d -v /d/work/yayi-home:/var/www/html/yayi-home --link newthink-mysql:mysql --link newthink-redis:redis php-yayi-home-img:latest
### 4.4 启动 php-yihuo-home-img 镜像, 生成容器
# docker run --name php-yihuo-home-app -d -v /d/work/yihuo-home:/var/www/html/yihuo-home --link newthink-mysql:mysql --link newthink-redis:redis php-yihuo-home-img:latest
### 4.5 启动 zhenglu-php-img 镜像, 生成容器
# docker run -d -v /d/work/zhenglu-php:/var/www/html/zhenglu-php --name zhenglu-app --link zhenglu-mysql:mysql zhenglu-php-img
### 4.6 启动 php-block-home-img 镜像, 生成容器
# docker run --name php-block-home-app -d -v /d/work/block-home:/var/www/html/block-home --link block-mysql:mysql --link block-redis:redis php-block-home-img:latest
### 4.7 启动 php-block-admin-img 镜像, 生成容器
# docker run --name php-block-admin-app -d -v /d/work/block-admin:/var/www/html/block-admin --link block-mysql:mysql --link block-redis:redis php-block-admin-img:latest
### 4.8 启动 php-ec-home-img 镜像, 生成容器
# docker run --name php-ec-home-app -d -v /d/work/ec-home:/var/www/html/ec-home --link block-mysql:mysql --link block-redis:redis php-ec-home-img:latest
### 4.9 启动 php-block-new-think-img 镜像, 生成容器
# docker run --name php-block-new-think-app -d -v /d/work/block-new-think:/var/www/html/block-new-think --link block-mysql:mysql --link block-redis:redis php-block-new-think-img:latest
### 4.10 启动 yayi-proxy-img 镜像, 生成容器
# docker run -p 3000:3000 --name yayi-proxy-app -v /d/work/yayi-proxy:/app --link php-new-think-app:newthink-app  yayi-proxy-img
### 4.11 启动 block-proxy-img 镜像, 生成容器
# docker run -p 3001:3001 --name block-proxy-app -v /d/work/block-proxy:/app --link php-block-new-think-app:blocknewthink-app  block-proxy-img
### 5 启动 nginx镜像
### 本机亚数项目的
# docker run --name nginx-yashu -p 80:80 -d -v /d/work/new-think/public/uploads/:/usr/share/nginx/uploads/new-think/uploads:ro -v /d/work/nginx-all/conf.d:/etc/nginx/conf.d/:ro -v /d/work/nginx-all/logs/nginx:/logs/nginx --link php-new-think-app:php-new-think-app --link php-yayi-admin-app:php-yayi-admin-app --link php-yayi-home-app:php-yayi-home-app --link php-yihuo-home-app:php-yihuo-home-app nginx

### 本机全部的nginx
# docker run --name nginx-all -p 80:80 -d -v /d/work/yayi-admin-vue/dist/:/usr/share/nginx/html/yayi-admin -v /d/work/yayi-home-vue/dist/:/usr/share/nginx/html/yayi-home -v /d/work/new-think/public/uploads/:/usr/share/nginx/uploads/new-think/uploads:ro -v /d/work/nginx-all/conf.d:/etc/nginx/conf.d/:ro -v /d/work/nginx-all/logs/nginx:/logs/nginx -v /d/work/zhenglu.html:/usr/share/nginx/html/zhenglu.html:ro -v /d/work/zhenglu-php/Application/Admin/Static:/usr/share/nginx/html/zhenglu-php/Application/Admin/Static:ro  -v /d/work/zhenglu-php/Application/Api_1/View/default:/usr/share/nginx/html/zhenglu-php/Application/Api_1/View/default:ro -v /d/work/zhenglu-php/Public:/usr/share/nginx/html/zhenglu-php/Public:ro -v /d/work/zhenglu-php/Uploads/Picture:/usr/share/nginx/html/zhenglu-php/Uploads/Picture:ro --link php-new-think-app:php-new-think-app --link php-yayi-admin-app:php-yayi-admin-app --link php-yayi-home-app:php-yayi-home-app --link zhenglu-app:zhenglu-app nginx

### 本地亚数&&上师nginx
# docker run --name nginx-all -p 80:80 -d -v /d/work/yayi-admin-vue/dist/:/usr/share/nginx/html/yayi-admin -v /d/work/yayi-home-vue/dist/:/usr/share/nginx/html/yayi-home -v /d/work/new-think/public/uploads/:/usr/share/nginx/uploads/new-think/uploads:ro -v /d/work/block-new-think/public/uploads/:/usr/share/nginx/uploads/block-new-think/uploads:ro -v /d/work/block-admin-vue/dist/:/usr/share/nginx/html/block-admin -v /d/work/block-home-vue/dist/:/usr/share/nginx/html/block-home -v /d/work/ec-home-vue/dist/:/usr/share/nginx/html/ec-home -v /d/work/nginx-all/conf.d:/etc/nginx/conf.d/:ro -v /d/work/nginx-all/logs/nginx:/logs/nginx --link php-new-think-app:php-new-think-app --link php-block-new-think-app:php-block-new-think-app --link php-yayi-admin-app:php-yayi-admin-app --link php-yayi-home-app:php-yayi-home-app --link php-yihuo-home-app:php-yihuo-home-app --link php-block-home-app:php-block-home-app --link php-block-admin-app:php-block-admin-app --link php-ec-home-app:php-ec-home-app nginx

# docker容器启动命令：docker start newthink-mysql block-mysql newthink-redis block-redis php-new-think-app php-block-new-think-app php-yayi-admin-app php-yayi-home-app php-yihuo-home-app php-block-home-app php-block-admin-app php-ec-home-app yayi-proxy-app block-proxy-app nginx-all

### 阿里云上的nginx
# docker run --name nginx-all8 -p 80:80 -d -v /work/shangxueyuan.html:/usr/share/nginx/html/shangxueyuan.html:ro -v /work/yayi-admin-vue/dist/:/usr/share/nginx/html/yayi-admin -v /work/block-admin-vue/dist/:/usr/share/nginx/html/block-admin -v /work/yayi-home-vue/dist/:/usr/share/nginx/html/yayi-home -v /work/yihuo-home-vue/dist/:/usr/share/nginx/html/yihuo-home -v /work/ec-home-vue/dist/:/usr/share/nginx/html/ec-home -v /work/block-home-vue/dist/:/usr/share/nginx/html/block-home -v /work/yayi-home-visitor-vue/dist/:/usr/share/nginx/html/yayi-home-visitor -v /work/yihuo-home-visitor-vue/dist/:/usr/share/nginx/html/yihuo-home-visitor -v /work/new-think/public/uploads/public/:/usr/share/nginx/uploads/new-think/uploads/public/:ro -v /work/block-new-think/public/uploads/public/:/usr/share/nginx/uploads/block-new-think/uploads/public/:ro -v /work/nginx-all/conf.d:/etc/nginx/conf.d/:ro -v /work/nginx-all/logs/nginx:/logs/nginx -v /work/zhenglu.html:/usr/share/nginx/html/zhenglu.html:ro -v /work/zhenglu-php/Application/Admin/Static:/usr/share/nginx/html/zhenglu-php/Application/Admin/Static:ro -v /work/zhenglu-php/Application/Zl/View/default/Public/js:/usr/share/nginx/html/zhenglu-php/Application/Zl/View/default/Public/js:ro -v /work/zhenglu-php/Application/Api_1/View/default:/usr/share/nginx/html/zhenglu-php/Application/Api_1/View/default:ro -v /work/zhenglu-php/Public:/usr/share/nginx/html/zhenglu-php/Public:ro -v /work/zhenglu-php/Uploads/Picture:/usr/share/nginx/html/zhenglu-php/Uploads/Picture:ro --link php-new-think-app:php-new-think-app --link php-block-new-think-app:php-block-new-think-app --link php-yayi-admin-app:php-yayi-admin-app --link php-block-admin-app:php-block-admin-app --link php-yayi-home-app:php-yayi-home-app --link php-block-home-app:php-block-home-app --link php-yihuo-home-app:php-yihuo-home-app --link php-ec-home-app:php-ec-home-app --link zhenglu-app:zhenglu-app nginx

# 测试网址 http://zhenglu.thinklev.com/Application/Zl/View/default/Public/js/bigmall_ly.js
# http://yayiadmin.local/index/index/index

# 测试 通过redis-cli 连接redis,运行完删除
# docker run -it --link newthink-redis:redis --rm redis redis-cli -h redis -p 6379

# 测试 使用 MySQL 命令行工具连接 MySQL
# docker run -it --link newthink-mysql:mysql --rm mysql sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'

#  docker start newthink-mysql newthink-redis php-new-think-app php-yayi-admin-app php-yayi-home-app php-yihuo-home-app yayi-proxy-app nginx-yashu


# 网红的docker启动流程
# 1 切换到new-think-celebrity目录下
# docker build -t php-new-think-img .
# 2 切换到celebrity-admin目录下
# docker build -t php-celebrity-admin-img .
# 3 切换到celebrity-home目录下
# docker build -t php-celebrity-home-img .
# 4 切换到yayi-proxy项目下
# docker build -t yayi-proxy-img .
# 5 启动mysql
# docker run --name newthink-mysql -v /mysqldata/newthink:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=caoshijie_sikao -p 3306:3306 -d mysql:8.0.1
# 6 启动redis
# docker run --name newthink-redis -d -v /redisdata/newthink:/data redis redis-server --appendonly yes
# 7 启动 php-new-think-img 镜像, 生成容器
# docker run --name php-new-think-app -d -v /work/new-think:/var/www/html/new-think --link newthink-mysql:mysql --link newthink-redis:redis php-new-think-img:latest
# 8 启动 php-celebrity-admin-img 镜像, 生成容器
# docker run --name php-celebrity-admin-app -d -v /work/celebrity-admin:/var/www/html/celebrity-admin --link newthink-mysql:mysql --link newthink-redis:redis php-celebrity-admin-img:latest
# 9 启动 php-celebrity-home-img 镜像, 生成容器
# docker run --name php-celebrity-home-app -d -v /work/celebrity-home:/var/www/html/celebrity-home --link newthink-mysql:mysql --link newthink-redis:redis php-celebrity-home-img:latest
# 10 启动 yayi-proxy-img 镜像, 生成容器
# docker run -p 3000:3000 --name yayi-proxy-app -v /work/yayi-proxy:/app --link php-new-think-app:newthink-app  yayi-proxy-img
# 11 启动 nginx
# docker run --name nginx-celebrity -p 80:80 -d -v /work/celebrity-admin-vue/dist/:/usr/share/nginx/html/celebrity-admin -v /work/celebrity-home-vue/dist/:/usr/share/nginx/html/celebrity-home -v /work/new-think/public/uploads/public/:/usr/share/nginx/uploads/new-think/uploads/public/:ro -v /work/nginx-all/conf.d:/etc/nginx/conf.d/:ro -v /work/nginx-all/logs/nginx:/logs/nginx --link php-new-think-app:php-new-think-app --link php-celebrity-admin-app:php-celebrity-admin-app --link php-celebrity-home-app:php-celebrity-home-app nginx